package src.main.java.org.oop.interfaceDemo2;

import java.util.ArrayList;

public class StudentOperatorImpl2 implements StudentOperator{

    @Override
    public void printAllInfo(ArrayList<Student> students) {
        System.out.println("--------全班全部信息如下--------------");
        int male = 0 ;
        int female = 0;
        for (int i = 0; i < students.size(); i++) {
            Student student = students.get(i);
            if(student.getSex()=='男'){
                male++;
            }else{
                female++;
            }
            System.out.println("姓名："+student.getName());
            System.out.println("性别："+student.getSex());
            System.out.println("分数："+student.getScore());
            System.out.println("-----------");

        }
        System.out.println("男生人数是："+male);
        System.out.println("女生人数是："+female);
        System.out.println("班级总人数是："+students.size());
        System.out.println("------------------");
    }

    @Override
    public void printAvgScore(ArrayList<Student> students) {
        double allScore = 0.0;
        double max = students.get(0).getScore();
        double min = students.get(0).getScore();
        for (int i = 0; i < students.size(); i++) {
            Student student = students.get(i);
            if(student.getScore()>max) max = student.getScore();
            if(student.getScore()<min) min = student.getScore();
            allScore += student.getScore();
        }
        System.out.println("学生最高分："+max);
        System.out.println("学生最低分："+min);
        System.out.println("去掉最高分和最低分的平均分:"+(allScore-max-min)/(students.size()-2));
    }
}
